﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.UI;
using Entity;

namespace School.Base
{
    public class PermissionBasePage : BasePage
    {
        public PermissionBasePage()
        {
            this.Init += new EventHandler(BasePage_Init);
            this.Load += new EventHandler(PermissionBasePage_Load);
            this.LoadComplete += new EventHandler(PermissionBasePage_LoadComplete);
        }

        protected void BasePage_Init(object sender, EventArgs e)
        {
            //验证用户是否已登录
            if (!CookieIsExist("UserLoginName"))
            {
                Response.Redirect("login.aspx");
            }

            
        }

        protected void PermissionBasePage_Load(object sender, EventArgs e)
        {
            
        }

        protected void PermissionBasePage_LoadComplete(object sender, EventArgs e)
        {
            //获取用户所拥有的操作权限
            string actions = GetCookie("UserRoleAction");
            char[] a = actions.ToCharArray();

            if (a[0].ToString() == "0") SetEditDisable();
            if (a[1].ToString() == "0") SetReviewDisable();
            if (a[2].ToString() == "0") SetViewDisable();
        }

        //设置编辑不可用
        public virtual void SetEditDisable() { }
        //设置审核不可用
        public virtual void SetReviewDisable() { }
        //设置查看不可用
        public virtual void SetViewDisable() { }
        
        
    }
}